package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysRequestsCheck;
import com.ruoyi.system.service.ISysRequestsCheckService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 接口校验Controller
 * 
 * @author yql
 * @date 2023-09-19
 */
@RestController
@RequestMapping("/system/check")
public class SysRequestsCheckController extends BaseController
{
    @Autowired
    private ISysRequestsCheckService sysRequestsCheckService;

    /**
     * 查询接口校验列表
     */
    @PreAuthorize("@ss.hasPermi('system:check:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysRequestsCheck sysRequestsCheck)
    {
        startPage();
        List<SysRequestsCheck> list = sysRequestsCheckService.selectSysRequestsCheckList(sysRequestsCheck);
        return getDataTable(list);
    }

    /**
     * 导出接口校验列表
     */
    @PreAuthorize("@ss.hasPermi('system:check:export')")
    @Log(title = "接口校验", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysRequestsCheck sysRequestsCheck)
    {
        List<SysRequestsCheck> list = sysRequestsCheckService.selectSysRequestsCheckList(sysRequestsCheck);
        ExcelUtil<SysRequestsCheck> util = new ExcelUtil<SysRequestsCheck>(SysRequestsCheck.class);
        util.exportExcel(response, list, "接口校验数据");
    }

    /**
     * 获取接口校验详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:check:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sysRequestsCheckService.selectSysRequestsCheckById(id));
    }

    /**
     * 新增接口校验
     */
    @PreAuthorize("@ss.hasPermi('system:check:add')")
    @Log(title = "接口校验", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysRequestsCheck sysRequestsCheck)
    {
        return toAjax(sysRequestsCheckService.insertSysRequestsCheck(sysRequestsCheck));
    }

    /**
     * 修改接口校验
     */
    @PreAuthorize("@ss.hasPermi('system:check:edit')")
    @Log(title = "接口校验", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysRequestsCheck sysRequestsCheck)
    {
        return toAjax(sysRequestsCheckService.updateSysRequestsCheck(sysRequestsCheck));
    }

    /**
     * 删除接口校验
     */
    @PreAuthorize("@ss.hasPermi('system:check:remove')")
    @Log(title = "接口校验", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysRequestsCheckService.deleteSysRequestsCheckByIds(ids));
    }
}
